<template>
	<view class="goods-item f-a-start">
		<image :src="$imgUrl(item.goods.image)" lazy-load mode="aspectFill" class="goods-img"></image>
		<view class="item-right">
			<view class="name ellipsis2">{{item.goods.name}}</view>
			<view class="spec">规格：{{item.goods.attr_name}}</view>
			<view class="price f-c-between">
				<span>¥{{item.goods.price}}</span>
				<u-number-box v-model="item.num" integer border bgColor="#ffffff" button-size="24" input-size="28rpx"
					inputWidth="30" :iconStyle="{fontSize:'26rpx'}" @change="e=>onNumChange(e,item.id)"></u-number-box>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "productItem",
		props: {
			//购物车每一项
			item: {
				type: Object,
				default: () => {}
			},
		},
		data() {
			return {
				value: 0
			};
		},
		methods: {
			//获取数量
			onNumChange(e, id) {
				this.$u.debounce(() => {
					this.$emit('onNumChange', e.value)
				}, 300)
			}
		},
	}
</script>

<style lang="scss">
	.goods-item {
		width: 100%;
		background-color: #ffffff;

		.goods-img {
			width: 152rpx;
			height: 152rpx;
			display: block;
			border-radius: 10rpx;
			margin-right: 22rpx;
		}

		.item-right {
			width: calc(100% - 174rpx);

			.name {
				// font-size: 24rpx;
				font-size: calc(24rpx * 1.2);
				line-height: 34rpx;
				color: #333333;
				height: 68rpx;
			}

			.spec {
				font-weight: 400;
				font-size: 24rpx;
				font-size: calc(24rpx * 1.2);
				color: #676767;
				margin-top: 6rpx;
			}

			.price {
				font-weight: 500;
				// font-size: 32rpx;
				font-size: calc(32rpx * 1.2);
				color: #EC673F;
				margin-top: 8rpx;
			}
		}
	}
</style>